﻿package desk.game.eatbean;

import javax.microedition.lcdui.Graphics;

public class MySprite {
	private int x,y,width,height,t;
	private boolean open=true;
	private int speed=0;
	Beans b;
	Enemy e;
	public MySprite(int x,int y,int width,int height)
	{
		this.x=x;
		this.y=y;
		this.width=width;
		this.height=height;
		b=new Beans();
		e=new Enemy();
		speed=10;
	}

	protected void paint(Graphics g) {
		open=!open;
		g.setColor(255, 0, 0);
		if(t==0)
		{
			if(open==true)
				g.fillArc(x, y, 20, 20, 0, 360);
			else
				g.fillArc(x, y, 20, 20, 15, 310);
		}
		if(t==6)
		{
			if(open==true)
				g.fillArc(x, y, 20, 20, 0, 360);
			else
				g.fillArc(x, y, 20, 20, 15, 310);
		}
		if(t==4)
		{
			if(open==true)
				g.fillArc(x, y, 20, 20, 0, 360);
			else
				g.fillArc(x, y, 20, 20, 205, 310);
		}
		if(t==2)
		{
			if(open==true)
				g.fillArc(x, y, 20, 20, 0, 360);	
			else
				g.fillArc(x, y, 20, 20, 115, 310);
		}
		if(t==8)
		{
			if(open==true)
				g.fillArc(x, y, 20, 20, 0, 360);	
			else
				g.fillArc(x, y, 20, 20, 295, 310);
		}
		b.eat(x, y);
	}
	public void move(int t)
	{
		this.t=t;
		switch(t)
		{
		case 2:y-=speed;break;
		case 8:y+=speed;break;
		case 4:x-=speed;break;
		case 6:x+=speed;break;
		}
		if(x<0)x=width;
		if(x>width)x=0;
		if(y<0)y=height;
		if(y>height)y=0;
	}
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public void setSpeed()
	{
		speed++;
	}
	public int getSpeed()
	{
		return speed;
	}
}
